<?php
namespace BP\GPM;
class DeptStations extends Entities {
	public static function constructor__ () 
	{
		$me = new self();
		return $me;
	}
	public static function constructor__String ($stationNo) // [String stationNo]
	{
		$me = new self();
		$qo = new QueryObject($me);
		$qo->AddWhere(DeptStationAttr::$FK_Station, $stationNo);
		$qo->DoQuery();
		return $me;
	}
	public function getNewEntity () 
	{
		return DeptStation::constructor__();
	}
	public function GetHisEmps ($stationNo) // [String stationNo]
	{
		$qo = new QueryObject($this);
		$qo->AddWhere(DeptStationAttr::$FK_Station, $stationNo);
		$qo->addOrderBy(DeptStationAttr::$FK_Station);
		$qo->DoQuery();
		$ens = Emps::constructor__();
		foreach ($this->ToJavaList() as $en) 		{
			$ens->AddEntity(Emp::constructor__String($en->getFK_Dept()));
		}
		return $ens;
	}
	public function GetHisStations ($empId) // [String empId]
	{
		$ens = Stations::constructor__();
		if ($Cash->IsExits(("DeptStationsOf" . $empId), $Depositary->Application))
		{
			return $Cash->GetObjFormApplication(("DeptStationsOf" . $empId), NULL);
		}
		else
		{
			$qo = new QueryObject($this);
			$qo->AddWhere(DeptStationAttr::$FK_Dept, $empId);
			$qo->addOrderBy(DeptStationAttr::$FK_Station);
			$qo->DoQuery();
			foreach ($this->ToJavaList() as $en) 			{
				$ens->AddEntity(Station::constructor__String($en->getFK_Station()));
			}
			$Cash->AddObj(("DeptStationsOf" . $empId), $Depositary->Application, $ens);
			return $ens;
		}
	}
	public function ToJavaList () 
	{
		return $this;
	}
	public function Tolist () 
	{
		$list = [];// 
		for ($i = 0; ($i < $this->size()); ++$i) 
		{
			$list->add($this->get($i));
		}
		return $list;
	}
}
?>
